home *** CD-ROM | disk | FTP | other *** search
- /**** TRACE CDEV COPYRIGHT 1990, 1991 ORION NETWORK SYSTEMS ALL RIGHTS RESERVED ****/
- #ifndef __CDEV__
- #define __CDEV__
-
- #include "tracemodule.h"
-
- #include <Dialogs.h>
- #include <Controls.h>
- #include <Types.h>
- #include <QuickDraw.h>
-
- /*********************************************************************/
- /************************ DEFINES ************************/
- /*********************************************************************/
-
- #define kFieldsPerBank 4 /* How many mask names per bank */
- // This is how many names fit in the cdev's scroll window.
- #define kBitsPerMask 128
-
-
- #define kOurKey 0x91726358
- #define kDefaultFileName "\pTracks Prefs"
- #define kTraceMaskID 0
- #define kBreakMaskID 1
-
- #define kMaxNumSizes 15 // Array size of buffer sizes...
-
- #define kCDEVCreator 'BNNY'
-
-
- /***** DITL items *****/
- enum
- {
- iTitleStr = 1,
- iOnChk,iOffChk,
- iOnMsg,iOffMsg,
- iErrorStr,iErrorNumberStatic,iErrorMsgStatic,
- iAutoWriteChk,iAutoWriteMsg,
- iConfigFileButton,iFileNameStatic,
- iFileSizeStr,iFileSizeStatic,iResetEOFButton,
- iBufferSizeStr,iBufferSizeStatic,iSizeIncrement,iSizeDecrement,
- iClearBufferButton,
- iBytesBufferedStr,iBytesBuffedStatic,
- iWriteBufferButton,
- iLevel1Button,iBkptEllipsisButton,iMaskNumStatic,
- iMaskEllipsisButton,
- iChecks_Start = 28,
- iDebugChecks_Start = 32,
- iNames_Start = 36,
- iScrollBarUserItem = 40,
- iLevel2Button,iLevel3Button,iLevel4Button
- };
-
- #define kBugPictureID -4062
- enum {kTraceMask,kBreakMask}; /* For getting and setting mask, (whichmask) */
- enum
- {
- kNoErrMsg=1,
- kDriverError,
- kBufferNotClear,
- kInitializationFail,
- kFileError,
- kUnimplementedError,
- kMemoryError,
- kVersionError
- };
-
- #define kNumberOfErrors 5 /* The number of messages in STR# resource */
-
- /***** Self definable *****/
-
- #define kNumberOfBanks (kBitsPerMask / kFieldsPerBank) /* 16 with 8 fields each.. */
- #define iChecks_End iChecks_Start + kFieldsPerBank-1
- #define iNames_End iNames_Start + kFieldsPerBank -1
- #define iDebugChecks_End iDebugChecks_Start + kFieldsPerBank -1
- #define kMaxBankSize kNumberOfBanks-1 /* 0..7 array of shex's */
- #define kMinBankSize 0
-
- #define kTraceErrorsID -4063 /* STR# list for error conditions */
-
- #define kInternalMsg -1 /* Used to report message to user via ReportResult */
- #define kSizeIndexDefault 1 /* BufferSize[kSizeIndexDefault] = startup default size */
-
-
- #define kExternalNamesListID 777 // STR# list in target app..
-
- #define kDotDrvrNameType 'kDRp' // holds ".ANSA" (pascal string)
- #define kDotDrvrNameID 128
-
- #define kDriverNameResType 'kDRp' // Holds target app's name
- #define kDriverNameResID 129 // eg "SNAps Access" (pascal string)
-
-
- /********************************************************************/
- /************************ THE T_CDEV CLASS **************************/
- /********************************************************************/
-
- class t_cdev {
- public:
-
- /* instance variables */
-
- /** Dispatch Globals */
- WindowPeek fDp; /* the Control Panel */
- short fWindRefnum; /* refnum of Control Panel DA */
- short fRsrcID; /* base resource ID */
- short fLastItem; /* # of last Control Panel item */
- EventRecord *fEvent; /* ==> last event */
- long fStatus; /* value to be returned */
- /* Driver Stuff */
- long fKey;
- short fTraceRefNum;
-
- ControlHandle fScrollBar; /* The scroll bar. Not a regular DITL for various reasons */
- Rect fSBarRect; /* Holds Rectangle area of scroll bar */
-
- MaskType fTraceMask; /* This the cdev's copy of the 128 bits of mask data */
- MaskType fBreakMask; /* 0-127 bit mask for breaking into debugger. */
-
- Boolean fBreakOnceThenClear; // If this is true, breakpoints
- // clear themselves after being called--
- // This is the default, so that the user
- // can be sure that it won't get called
- // so often and repeatedly, that he won't
- // have time to turn off the break points
- // with the cdev.
- Boolean fTraceOnStartup; // This will allow the user
- // to have the driver install and begin
- // tracing from startup (reboot).
- // Not currently implemented.
- short fMaskIndex; /* Keeps track of which bank of mask names is shown */
- Boolean fAutoWriteOn; /* Periodic write to file on/off */
- Boolean fTraceEnabled; /* Trace on or off */
-
- lhex fBytesWritten; /* Size of Output file */
- lhex fBytesBuffered; /* Bytes in buffer */
-
- shex fCurrentSizeIndex; /* which of buffer size is current */
- lhex fBufferSize; /* Actual Buffer Size */
- shex fBufferNumSizes;// # pos. sizes. defined in init.cp
- lhex fBufSizesHandle[kMaxNumSizes]; // array of sizes.. (0-1M)
- TraceStatusBlk fTraceStatus; /* Holds most current trace status record... */
-
- PicHandle fBugPicture; /* Shows that a breakpoint has been set.. */
-
- Handle fFieldNames; // Handle to copy of Str# resource
- Handle fDriverDotName; // Such as "\p.ASNA"
- Handle fTargetAppName; // Such as "\pSNAps Access"
-
- // long fTargFileDirID; // directoryID for the target driver's file
- // long fPrefFileDirID; // directoryID for the target driver's file
- long unused1;
- long unused2;
-
- Boolean fInCDEVMode; // as opposed to inExtended...
-
- // These are semi-constants, in that they only change when the dialog
- // switches from the cdev to the extended dialog... and vice versa.
- // (To switch to the extended mode, hit the Extended Dialog… button in the cdev.
- //
- short fMinBankSize,fMaxBankSize,fFieldsPerBank;
- short fChecks_Start,fChecks_End,fNames_Start,fNames_End;
- short fDebugChecks_Start, fDebugChecks_End;
- short fMaskNumStatic,fErrorMsgStatic,fErrorNumberStatic;
-
- Str31 fDefaultFileName;
- SysEnvRec fEnvironment;
-
-
- /* METHODS */
-
- /***** Methods that call the trace driver */
-
- public:
- long Message(short, short); /* dispatch message */
- void Error(long); /* set error return */
- void ChangeBank(short NewBankNumber);
-
- private:
- snum TraceInit(); /* Called once at startup... If failed, returns false */
- OSErr EnableTrace(Boolean On);
- OSErr EnableBuffer(Boolean On);
- OSErr EnableFile(char *fName,short vRefNum); /* Called to set the file name */
- OSErr ToggleAutoWrite();
- OSErr DriverToCdevMask(short csCode); // Gets Driver's copy of mask
- OSErr CdevMaskToDriver(short csCode); // Sends Cdev's copy of mask to driver
- void ResetEOF(); /* Sets EOF of current output file to Zero */
- void WriteBufferNow();
- void ClearBufferNow();
- void ReportResult(short result,short MsgNum); /* Simply puts result code in dialog, */
- OSErr UpdateTraceStatusBlk(void);
- void BreakPointHelp(void);
- void GetFieldName(char *itemName, short index);
-
-
- short GetFolderVol(OSType type);
-
-
- // Prefrence stuff
- void DoLoad();
- Boolean LoadFieldNames();
- void GetTargAppStuff(); // gets Str# list & fDriverDotName
-
-
- /* Standard CDEV calls that are overridden */
-
- OSErr Init(void); /* "initDev" */
- void Update(void); /* "updateDev" */
- void Activate(void); /* "activDev" */
- void Deactivate(void); /* "deactiveDev" */
- void ItemHit(short); /* "hitDev" */
- void Key(short); /* "keyEvtDev" */
- void Close(); /* "CloseDev" */
- void Idle(void); /* "nulDev" */
-
- /* DITL manipulation methods */
-
- void DGetString(short item,Str255 str);
- void DSetString(short item,Str255 str);
- void DSetLong(short item,long value);
- void DSetControl(short theitem,short value);
- void DEnableControl(ControlHandle Control,Boolean Enable);
- void DEnableItem(short item,Boolean Enable);
- void GetDItemFrame(short item,Rect *r);
- Boolean TrackItem(int item); /* Tracks Mouse in Pict D. Item */
- void DHidePictItem(short theitme,Boolean Enable);
- void DrawABug(short theitem,Boolean Draw); /*Draws or Erases Debugger() bug symbol */
-
- /* Scroll bar routines */
- void HandleScrollBar(void);
-
- /* Checks and scroll field.... */
- void CheckMarkHit(short);
- void DebugMarkHit(short);
- void UpdateFields();
- /********************** Alternate DLOG Screen ****************/
- void ExtendedClose(Ptr saveGlobs);
- Boolean ExtendedSetup(Ptr saveGlobs);
- void DoExtendedView();
-
-
- void DoCopyMask(MaskType src, MaskType dst);
-
- /***** BUTTON ACTIONS *****/
-
- void SetOnOff(Boolean On);
- void SetSize(short whichhit);
- void FillMask(short WhichMask, Boolean SetCondition);
- void SetName();
- void DoSave(Boolean JustErasePrefs);
-
-
- /* Menu Stuff (ignored) */
- void CmdKey(short); /* "keyEvtDev" (command) */
-
-
- };
-
- pascal void ScrollFilter(ControlHandle SBar,short partCode); /* for scroll bar */
-
- // *************************************************************************************** //
- // Extended Dialog Stuff for CDEV.
-
- // Dialog Item List ID's
- enum {keOkayButton = 1,keCancelButton,keNamesStart,keNamesEnd = 18,
- keDebugAreaStart,keDebugAreaEnd=34,keChecksStart,keChecksEnd = 50,
- keScrollBarArea,
- keClearAll,keSetAll,keClearBreakPts,keClearOnceCheckBox,keSave,keLoad,keAutoWrite,
- keChangesInfo,keMaskNumStatic,keTraceOnStartup,keErrorNumberStatic,keErrorMsgStatic,keRevertPrefs};
-
-
- // There will be eight screens (banks) of mask names (0-7) in the scrollable field.
- // of the larger scroll area. This is in the recommended system font
- // size.
-
- #define kExtendedDialogID -4062
- #define keMinBankSize 0
- #define keMaxBankSize 7
- #define keFieldsPerBank 16
-
- typedef struct
- {
- ControlHandle ScrollBarControl;
- short MaskIndex;
- Boolean TraceStartup; // Ability to trace from init startup
- Boolean InitialTraceState;
- Boolean BOTCCopy;
- Boolean AutoWriteOn;
- WindowPeek DP;
- short LastItem;
- lhex BreakMaskCopy[4];
- lhex TraceMaskCopy[4];
- } SavedGlobals, *SavedGlobalsPtr;
-
-
-
-
-
-
-
- #endif
-